function ProdGen($, com, Swiper) {
	var PrdInfoMaker = {
		init: function (container, data) {
			var _this = this;
			var html = "";
			html += _this.htmlNavs();
			html += _this.htmlMain(data);
			$(container).html(html);
			var swiper = new Swiper('.prdRmkSwiper', {
				lazy: true,
				observer: true,
				observerParents: true,
			});
			_this.bindEvents();
		},
		htmlNavs: function () {
			var _this = this;
			var html = "";
			html += '<div class="prd-navs"> ';
			html += '	<div tg="1" class="prd-nav active">产品描述</div> ';
			html += '	<div tg="2" class="prd-nav ">产品参数</div> ';
			html += '	<div tg="3" class="prd-nav">适用车型</div> ';
			html += '</div> ';
			return html;
		},
		htmlMain: function (data) {
			var _this = this;
			var html = "";
			html += '<div class="prd-main">';
			html += '	<div class="prd-bodys">';
			html += _this.genPrdRmk(data); //产品描述
			html += _this.genPrdParam(data);//产品参数
			html += _this.genVehicles(data);//使用车型
			html += '	</div>';
			html += '</div>';
			return html;
		},
		genPrdRmk: function (data) {
			var _this = this;
			var html = "";
			html += '<div tg="1" class="prd-body"> ';
			html += '	<div class="swiper-container prdRmkSwiper"> ';
			html += '		<div class="swiper-wrapper" id="pics"> ';
			$(data.desList1).each(function (idx, img) {
				html += '		<div class="swiper-slide"> ';
				html += '			<img src="' + (com.Config.domain + data.lj + img.reserve5) + '" /> ';
				html += '		</div> ';
			});
			html += '		</div> ';
			html += '	</div> ';
			html += '	<ul class="prd-rmk"> ';
			html += '		<li><span class="left">零件号：</span><span>' + data.desList[0].reserve2 + '</span></li> ';
			html += '		<li><span class="left">德科号：</span><span>' + data.desList[0].reserve3 + '</span></li> ';
			html += '		<li><span class="left">零件名称：</span><span>' + data.desList[0].reserve1 + '</span></li> ';
			html += '		<li><span class="left">产品系列</span><span>' + data.desList[0].reserve4 + '</span></li> ';
			html += '	</ul> ';
			html += '</div> ';
			return html;
		},
		genPrdParam: function (data) {
			var _this = this;
			var html = "";
			html += '<div tg="2" class="prd-body"> ';
			html += '	<table class="prd-param prd-rmk"> ';
			$(data.partList).each(function () {
				html += '		<tr><td class="left">' + this.brandName + '：</td><td>' + com.utils().textIfEmpty(this.modelName) + '</td></tr> ';
			});
			html += '	</table> ';
			html += '</div> ';
			return html;
		},
		genVehicles: function (data) {
			var _this = this;
			var html = "";
			var trs = "";
			html += '<div  tg="3" class="prd-body"> ';
			html += '	<div class="more-info-tool"> ';
			html += '		<img src="/mb/frontlib/img/arrow.gif" /> ';
			html += '	</div> ';
			html += '	<div class="prd-vechiles"> ';
			html += '		<table class="tb"> ';
			html += '	  <thead>';
			html += '		<th >品牌</th>';
			html += '		<th >车型</th>';
			html += '		<th >车型结构</th>';
			html += '		<th >排量(L)</th>';
			html += '		<th >发动机型号</th>';
			html += '		<th >功率（KW）</th>';
			html += '		<th >车型起始日期</th>';
			html += '		<th >车型停产日期</th>';
			html += '		<th >适配备注</th>';
			html += '		<th >适配变速箱类型</th>';
			html += '		<th >适配刹车盘备注</th>';
			html += '		<th >配件适用车型起始年份;</th>';
			html += '		<th >配件适用车型截止年份</th>';
			html += '		<th >安装位置</th>';
			html += '	  </thead>';
			html += '	  <tbody>';
			if (data.selectVehicleNoByPart) {
				$(data.selectVehicleNoByPart).each(function (idx, obj) {
					trs += '<tr>' +
						'<td>' + (obj.BRAND_NAME || "") + '</td>' +
						'<td>' + (obj.MODEL_NAME || "") + '</td>' +
						'<td>' + (obj.FRAME_STRUCTURE || "") + '</td>' +
						'<td>' + (obj.DISPLACEMENT_L || "") + '</td>' +
						'<td>' + (obj.ENGINE_NO || "") + '</td>' +
						'<td>' + (obj.POWER_KW || "") + '</td>' +
						'<td>' + com.utils().formatDateYYmm(obj.START_DATE) + '</td>' +
						'<td>' + com.utils().formatDateYYmm(obj.STOP_DATE) + '</td>' +
						'<td>' + (obj.spbz || "") + '</td>' +
						'<td>' + (obj.spbsxlx || "") + '</td>' +
						'<td>' + (obj.spscpbz || "") + '</td>' +
						'<td>' + com.utils().formatDateYYmm(obj.pjsycxqsnf) + '</td>' +
						'<td>' + com.utils().formatDateYYmm(obj.pjsycxjznf) + '</td>' +
						'<td>' + (obj.azwz || "") + '</td>' +
						'</tr>';
				});
			} else {
				trs = '<tr>' +
					'<td>&nbsp;</td>' +
					'<td>&nbsp;</td>' +
					'<td>&nbsp;</td>' +
					'<td>&nbsp;</td>' +
					'<td>&nbsp;</td>' +
					'<td>&nbsp;</td>' +
					'<td>&nbsp;</td>' +
					'<td>&nbsp;</td>' +
					'<td>&nbsp;</td>' +
					'<td>&nbsp;</td>' +
					'<td>&nbsp;</td>' +
					'<td>&nbsp;</td>' +
					'<td>&nbsp;</td>' +
					'<td>&nbsp;</td>' +
					'</tr>';
			}
			html += trs;
			html += '	  </tbody>';
			html += '		</table> ';
			html += '	</div> ';
			html += '</div> ';
			return html;
		},
		bindEvents: function () {
			$(".prd-nav").on("click", function () {
				$(".prd-nav").removeClass("active");
				$(this).addClass("active");
				var tg = $(this).attr("tg");
				if (tg == 1) {
					$(".prdRmkSwiper").find("img").css("visibility","visible")
				}else{
					$(".prdRmkSwiper").find("img").css("visibility","hidden")
				}
				var left = (-1 * (tg - 1) * 6.6) + "rem";
				$(".prd-bodys").animate({ "margin-left": left }, 500);
			});

		}
	};
	return {
		genPartInfo: function (paramsList, callback, noselect) {
			var optArr = [];
			var html = "";
			$(paramsList).each(function (idx, obj) {
				if (idx == 0) {
					$(obj.name).each(function (idx1, item1) {
						optArr.push({
							name: item1,
							values: []
						});
					});
				}
				html += "<tr tg='" + this.PART_NUMBER + "'>";
				html += "<td>" + this.PART_NUMBER + "</td>";
				html += "<td>" + this.PART_NAME_CN + "</td>";
				html += "<td>" + this.prodLine + "</td>";
				$(obj.value).each(function (idx2, item2) {
					optArr[idx2].values.push(item2);
					html += "<td>" + item2 + "</td>";
				});
				html += "</tr>";
			});
			var ths = '<tr><th style="min-width:1.6rem">零件号</th>';
			ths += '<th style="min-width:3.4rem">零件名称</th>';
			ths += '<th style="min-width:2rem">产品系列</th>';
			if (noselect) {
				$(optArr).each(function () {
					ths += '<th style="white-space: nowrap;padding:0 0.1rem;">' + this.name + '</th>'
				});
			} else {
				$(optArr).each(function () {
					var tmps = com.utils().uniqueArr(this.values);
					tmps = com.utils().sortArr(tmps);
					ths += '<th style="position:relative;"><button class="part-tool">' + this.name + '<i></i></button>';
					var tmpInfo = '<div class="part-tool-subs"><ul><li class="part-tool-sub">全部</li>'
					$(tmps).each(function (idx, obj) {
						tmpInfo += '<li class="part-tool-sub">' + obj + '</li>'
					});
					tmpInfo += '</ul></div>';
					ths += tmpInfo;
					ths += '</th>'
				});
			}
			ths += '</tr>';
			$(".parts-info").find("thead").html(ths);
			$(".parts-info").find("tbody").html(html);

			$(".part-tool").on("click", function () {
				if ($(this).hasClass("active")) {
					$(this).removeClass("active")
				} else {
					$(".part-tool").removeClass("active");
					$(this).addClass("active")
				}
			});

			$(".parts-info").find("tbody").find("tr").on("click", function () {
				$(".parts-info").find("tbody").find("tr").removeClass("active");
				$(this).addClass("active");
				callback.call(null, $(this).attr("tg"));
			});

			$(".part-tool-sub").on("click", function () {
				$(this).parent().parent().parent().find(".part-tool").removeClass("active");
				var txt = $(this).text();
				if (txt == "全部") {
					txt = "";
				}
				$(this).parent().parent().parent().find(".part-tool").attr("tg", txt);
				filterTb();
			});

			function filterTb() {
				var condition = [];
				$(".part-tool").each(function () {
					condition.push($(this).attr("tg"));
				});
				var def = 3;
				$(".parts-info").find("tbody").find("tr").each(function () {
					var tds = $(this).find("td");
					var res = true;
					for (var i = 0; i < condition.length; i++) {
						if (!condition[i]) {
							continue;
						}
						if ($(tds[def + i]).text() != condition[i]) {
							res = false;
							break;
						}
					}
					if (!res) {
						$(this).hide();
					} else {
						$(this).show();
					}
				});

			}
		},
		genPrdInfo: function (container, data) {
			PrdInfoMaker.init(container, data);
		}
	}
}
if ("function" == typeof define && define.amd && define) {
	define(['zepto', 'common/mcommon', 'swiper'], function ($, com, swiper) {
		return ProdGen($, com, swiper);
	});
}